package com.chao.mail.api.dto

import org.springframework.web.multipart.MultipartFile
import java.util.*

/**
 *
 */
data class MailSendMessage(
    val from: String,
    val to: String,
    val subject: String,
    val text: String,
    var sentDate: Date?,
    var cc: String?,
    var bcc: String?,
    var multipartFiles: Array<MultipartFile>?
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as MailSendMessage

        if (from != other.from) return false
        if (to != other.to) return false
        if (subject != other.subject) return false
        if (text != other.text) return false
        if (sentDate != other.sentDate) return false
        if (cc != other.cc) return false
        if (bcc != other.bcc) return false
        if (multipartFiles != null) {
            if (other.multipartFiles == null) return false
            if (!multipartFiles.contentEquals(other.multipartFiles)) return false
        } else if (other.multipartFiles != null) return false

        return true
    }

    override fun hashCode(): Int {
        var result = from.hashCode()
        result = 31 * result + to.hashCode()
        result = 31 * result + subject.hashCode()
        result = 31 * result + text.hashCode()
        result = 31 * result + sentDate.hashCode()
        result = 31 * result + (cc?.hashCode() ?: 0)
        result = 31 * result + (bcc?.hashCode() ?: 0)
        result = 31 * result + (multipartFiles?.contentHashCode() ?: 0)
        return result
    }
}

